package com.dycloud.project.controller.user;

import com.dycloud.project.domain.IndustryTrends;
import com.dycloud.project.enums.ReviewStatusEnum;
import com.dycloud.project.interceptor.annotation.RepeatSubmit;
import com.dycloud.project.service.IIndustryTrendsService;
import com.dycloud.project.web.controller.BaseController;
import com.dycloud.project.web.domain.AjaxResult;
import com.dycloud.project.web.page.TableDataInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;



/**
 * @author : renhang
 * @description UserIndustryTrendsController
 * @date : 2025-07-02 22:05
 **/
@RestController
@RequestMapping("/user/industryTrends")
public class UserIndustryTrendsController extends BaseController {

    @Resource
    private IIndustryTrendsService industryTrendsService;

    /**
     * 查询行业动态新闻列表
     */
    @GetMapping("/list")
    public TableDataInfo list(IndustryTrends industryTrends) {
        startPage();
        // 只能看到已发布的新闻
        industryTrends.setStatus(ReviewStatusEnum.PUBLISHED.getCode());
        return industryTrendsService.selectIndustryTrendsList(industryTrends);
    }

    /**
     * 获取行业动态新闻详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(industryTrendsService.selectIndustryTrendsById(id));
    }

    /**
     * 浏览行业动态新闻+1
     */
    @GetMapping("/view/{id}")
    @RepeatSubmit(interval = 2000)
    public AjaxResult view(@PathVariable Long id) {
        industryTrendsService.view(id);
        return AjaxResult.success();
    }


}
